<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>数据库 | Civet</title>
    <meta name="generator" content="VuePress 1.8.2">
    <script><script>
      var _hmt = _hmt || [];
      (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?08b17645d432072313c3f98d7882e0e3";
        var s = document.getElementsByTagName("script")[0]; 
        s.parentNode.insertBefore(hm, s);
      })();
      </script></script>
    <meta name="description" content="Civet是一款开源管理软件。它的目标是提供各种资源的管理，使快速查找需要的数据和信息成为可能">
    
    <link rel="preload" href="/civet/assets/css/0.styles.8803039f.css" as="style"><link rel="preload" href="/civet/assets/js/app.1af450a9.js" as="script"><link rel="preload" href="/civet/assets/js/2.ffed207c.js" as="script"><link rel="preload" href="/civet/assets/js/8.4b89ed42.js" as="script"><link rel="prefetch" href="/civet/assets/js/10.f03f3b42.js"><link rel="prefetch" href="/civet/assets/js/11.6a9e71ae.js"><link rel="prefetch" href="/civet/assets/js/12.2417a192.js"><link rel="prefetch" href="/civet/assets/js/13.5483ce60.js"><link rel="prefetch" href="/civet/assets/js/14.82103fcd.js"><link rel="prefetch" href="/civet/assets/js/15.57c10309.js"><link rel="prefetch" href="/civet/assets/js/16.2b18aecc.js"><link rel="prefetch" href="/civet/assets/js/17.2e400870.js"><link rel="prefetch" href="/civet/assets/js/18.29d6b649.js"><link rel="prefetch" href="/civet/assets/js/19.b865e518.js"><link rel="prefetch" href="/civet/assets/js/20.eee335fb.js"><link rel="prefetch" href="/civet/assets/js/3.9bce107b.js"><link rel="prefetch" href="/civet/assets/js/4.e085eee8.js"><link rel="prefetch" href="/civet/assets/js/5.cb5266fb.js"><link rel="prefetch" href="/civet/assets/js/6.e32fecab.js"><link rel="prefetch" href="/civet/assets/js/7.0388f924.js"><link rel="prefetch" href="/civet/assets/js/9.82a5d3a9.js">
    <link rel="stylesheet" href="/civet/assets/css/0.styles.8803039f.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="inner"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/civet/" class="home-link router-link-active"><!----> <span class="site-name">Civet</span></a> <div class="links"><nav class="nav-links can-hide"><div class="nav-item"><a href="/civet/introduction.html" class="nav-link">介绍</a></div><div class="nav-item"><a href="/civet/frame.html" class="nav-link">整体框架</a></div><div class="nav-item"><a href="/civet/frontend.html" class="nav-link">前端</a></div><div class="nav-item"><a href="/civet/extension.html" class="nav-link">扩展</a></div><div class="nav-item"><a href="/civet/db.html" aria-current="page" class="nav-link router-link-exact-active router-link-active">数据库</a></div><div class="nav-item"><a href="/civet/market.html" class="nav-link">扩展市场</a></div><div class="nav-item"><a href="https://github.com/webbery/civet" target="_blank" rel="noopener noreferrer" class="nav-link external">
  GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav> <div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div></div></div></header> <div class="sidebar-mask"></div> <div class="docs-layout"><aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/civet/introduction.html" class="nav-link">介绍</a></div><div class="nav-item"><a href="/civet/frame.html" class="nav-link">整体框架</a></div><div class="nav-item"><a href="/civet/frontend.html" class="nav-link">前端</a></div><div class="nav-item"><a href="/civet/extension.html" class="nav-link">扩展</a></div><div class="nav-item"><a href="/civet/db.html" aria-current="page" class="nav-link router-link-exact-active router-link-active">数据库</a></div><div class="nav-item"><a href="/civet/market.html" class="nav-link">扩展市场</a></div><div class="nav-item"><a href="https://github.com/webbery/civet" target="_blank" rel="noopener noreferrer" class="nav-link external">
  GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <!----></nav>  <ul class="sidebar-links"><li><a href="/civet/introduction.html" class="sidebar-link">介绍</a></li><li><a href="/civet/frame.html" class="sidebar-link">整体框架</a></li><li><a href="/civet/frontend.html" class="sidebar-link">前端</a></li><li><a href="/civet/extension.html" class="sidebar-link">扩展</a></li><li><a href="/civet/db.html" aria-current="page" class="active sidebar-link">数据库</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/civet/db.html#查询语法" class="sidebar-link">查询语法</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/civet/db.html#查询概要信息" class="sidebar-link">查询概要信息</a></li><li class="sidebar-sub-header"><a href="/civet/db.html#查询某个文件详细信息" class="sidebar-link">查询某个文件详细信息</a></li><li class="sidebar-sub-header"><a href="/civet/db.html#查询标签" class="sidebar-link">查询标签</a></li><li class="sidebar-sub-header"><a href="/civet/db.html#查询分类" class="sidebar-link">查询分类</a></li><li class="sidebar-sub-header"><a href="/civet/db.html#按条件查找相关的文件" class="sidebar-link">按条件查找相关的文件</a></li></ul></li><li class="sidebar-sub-header"><a href="/civet/db.html#添加-修改数据" class="sidebar-link">添加/修改数据</a></li><li class="sidebar-sub-header"><a href="/civet/db.html#结构" class="sidebar-link">结构</a></li></ul></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="数据库"><a href="#数据库" class="header-anchor">#</a> 数据库</h1> <p>数据库civetkern基于共享内存存储引擎lmdb开发，并使用PEGTL构建了查询引擎。</p> <h2 id="查询语法"><a href="#查询语法" class="header-anchor">#</a> 查询语法</h2> <p>类似于mongodb，实现了部分查询语法，同时针对应用本身，定义了几个关键字</p> <h3 id="查询概要信息"><a href="#查询概要信息" class="header-anchor">#</a> 查询概要信息</h3> <p>这里的概要信息是指，文件id、文件名、是否已分类/标签<br>
检索所有文件的概要信息：<code>{snap: '*'}</code><br>
分页检索，例如查看第3页，每页100张图片：<code>{snap: {limit: 100, offset: 100*2}}</code></p> <h3 id="查询某个文件详细信息"><a href="#查询某个文件详细信息" class="header-anchor">#</a> 查询某个文件详细信息</h3> <h3 id="查询标签"><a href="#查询标签" class="header-anchor">#</a> 查询标签</h3> <ol><li>查询标签的概要信息</li> <li>查询单个文件的标签内容</li></ol> <h3 id="查询分类"><a href="#查询分类" class="header-anchor">#</a> 查询分类</h3> <h3 id="按条件查找相关的文件"><a href="#按条件查找相关的文件" class="header-anchor">#</a> 按条件查找相关的文件</h3> <ol><li>按关键字搜索，示例如下：<br> <code>{keyword: '海洋'}</code><br>
也可以使用数组形式：{keyword: ['海洋']}</li> <li>标签搜索</li> <li>日期搜索<br>
大于某个时刻点：{datetime: {$gt: new Date('2020-09-20T00:00:00.000Z')}}<br>
如果要小于某个时刻点，需要将<code>$gt</code>修改未<code>$lt</code></li> <li>分类搜索</li> <li>按元信息搜索<br>
按元信息进行搜索功能是针对扩展进行的搜索。例如按颜色搜索: {color: {$near: '#343e58'}}, 按类型检索: {type: ['jpg']}</li></ol> <h2 id="添加-修改数据"><a href="#添加-修改数据" class="header-anchor">#</a> 添加/修改数据</h2> <h2 id="结构"><a href="#结构" class="header-anchor">#</a> 结构</h2></div> <footer class="page-edit"><!----> <!----></footer> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/civet/extension.html" class="prev">
          扩展
        </a></span> <!----></p></div> </main></div></div><div class="global-ui"></div></div>
    <script src="/civet/assets/js/app.1af450a9.js" defer></script><script src="/civet/assets/js/2.ffed207c.js" defer></script><script src="/civet/assets/js/8.4b89ed42.js" defer></script>
  </body>
</html>
